//
//  DrawMoneyNet.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/11/15.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//

#import "DrawMoneyNet.h"
#import "BLHeader.h"
#import "BasicNetManager.h"
#import <YYModel.h>
#import "Profit.h"

@implementation DrawMoneyNet

+ (void)DrawMoney: (NSString *)money completer:(void (^)(id result, NSError *error)) completer {
    BasicNetManager *manager = [BasicNetManager share];
    NSString *tel  = [[NSUserDefaults standardUserDefaults] objectForKey:USERTEL];
    NSDictionary *dic = @{@"userTel" : tel, @"freeMoney" : money};
    [manager postURL:DRAWMONEY param:dic completer:^(id result, NSError *error) {
        if (completer) {
            //NSLog(@"%@",result);
            completer(result,error);
        }
    }];
    
}

#pragma mark 提现记录
+ (void)DrawMoneyRecoder:(void (^)(id result, NSError *error))completer {
    BasicNetManager *manager = [BasicNetManager share];
    NSString *tel  = [[NSUserDefaults standardUserDefaults] objectForKey:USERTEL];
    NSDictionary *dic = @{@"userTel" : tel};
    [manager postURL:DRAWMONEYRECODER param:dic completer:^(id result, NSError *error) {
        if (completer) {
            NSMutableArray *array = [[NSMutableArray alloc] init];
            Profit *profit;
            if (result) {
                for (NSDictionary *dic in result) {
                        profit = [Profit yy_modelWithJSON:dic];
                        [array addObject:profit];
                }
               
            }
            completer(array,error);
        }
    }];
}

#pragma mark 收益记录
+ (void)PROFITRecoder:(void (^)(id result, NSError *error))completer {
    BasicNetManager *manager = [BasicNetManager share];
    NSString *tel  = [[NSUserDefaults standardUserDefaults] objectForKey:USERTEL];
    NSDictionary *dic = @{@"userTel" : tel};
    [manager postURL:PROFITMONEYRECODER param:dic completer:^(id result, NSError *error) {
        if (completer) {
            NSMutableArray *array = [[NSMutableArray alloc] init];
            Profit *profit;
            if (result) {
                for (NSDictionary *dic in result) {
                    profit = [[Profit alloc] init];
                    profit.t_money = [dic objectForKey:@"earnMoney"];
                    profit.t_msg = [dic objectForKey:@"earnMsg"];
                    profit.userTel = [dic objectForKey:@"userTel"];
                    [array addObject:profit];
                }
                
            }
            completer(array,error);
        }
    }];
}

@end
